package com.demo.webflux.spring5core.framework.aop.aspect;

import java.lang.reflect.Method;

import com.demo.webflux.spring5core.framework.aop.intercept.MethodInterceptor;
import com.demo.webflux.spring5core.framework.aop.intercept.MethodInvocation;

public class AfterThrowingAdvice extends AbstractAspectAdvice implements Advice, MethodInterceptor {

	private String throwingName;

	public AfterThrowingAdvice(Method aspectMethod, Object target) {
		super(aspectMethod, target);
	}

	public void setThrowingName(String name) {
		throwingName = name;
	}

	@Override
	public Object invoke(MethodInvocation mi) throws Throwable {
		try {
			return mi.process();
		}catch (Throwable ex) {
			invokeAdviceMethod(mi, null, ex.getCause());
			throw ex;
		}
	}

}
